﻿@using OBUCare.Core.Models
@using OBUCare.Web.Models
@using OBUCare.Web.Infrastructure
@model View_TRANSFER_BILL_Info

@{
    Layout = "";
    bool isPreveiw = (bool)ViewBag.IsPreView;
    string actionName = ViewBag.ActionName as string;  
}

@*<h2>@ViewBag.Title</h2>*@


<link href="../../Content/Site.css" rel="stylesheet" type="text/css" />
@using (Html.BeginForm(actionName, "Transfer", FormMethod.Post, new { @id = "TransferForm" }))
{
    <div id="divPrintArea" style="font-size:10px;">

        <center><h2>@ViewBag.Title</h2></center>
        <br />

        <!--显示详情列表-->
        @Html.Partial("_TransferGrid")


        <div id="dv1" style="display: none">
            @Html.Partial("_TransferBillToP")
        </div>
    </div>
    <div id="div_TransferBill">
        @Html.Partial("_TransferBill", Model)
    </div>
    
    if (!isPreveiw)
    { 
        @Html.Hidden("strIDs", ViewBag.strIDs as string, new { @id = "strIDs" })
        @Html.Hidden("TransferType", ViewBag.TransferType as string, new { @id = "TransferType" })
    }
    else
    { 
        @Html.Hidden("id", ViewBag.ID as string, new { @id = "id" })
    }
}

@using (Html.BeginForm("Export", "Transfer", FormMethod.Post, new { @id = "ExportForm" }))
{
    @Html.Hidden("exportID", ViewBag.ID as string, new { @id = "exportID" })
}


<script type="text/javascript">

//    $().ready(function () {
//        document.getElementById("dv1").setAttribute("style", "display:none");
//    });

    function btnCheckRecive() {
        //debugger;
            if ('@isPreveiw' == 'False') {
                if (!window.confirm("确定交接?"))
                    return;
                //getDropDownListText();
                submitTransferForm();
            }
            else {
               // debugger;
                ConfirmReceived();
                window.opener.location.reload();
            }

    }
    //交接
    function submitTransferForm() {
        var form = $("#TransferForm");
        dataString = form.serialize();

        $.ajax({
            type: "POST",
            url: form.attr('action'),
            data: dataString,
            cache: false,
            dataType: "json",
            success: function (data) {
              
                if (data.success) {
                    alert('交接成功');
                    $("#div_TransferBill").html(data.Html);
                    $("#btnSubmit").hide();
                    showRemark();
                }
                else {
                    alert('交接失败：' + data.message)
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                var err = XMLHttpRequest + "<br />" + textStatus + "<br />" + errorThrown;
                alert(err);
            }
        });
    }

    //确认接收
    function ConfirmReceived() {
        if (!window.confirm("确定接收?"))
            return;

        var form = $("#TransferForm");
        //交接单号
        var id =$("#id").val();
        var jdata = {id: id };
        $.ajax({
            type: "POST",
            url: form.attr('action'),
            data: jdata,
            cache: false,
            dataType: "json",
            success: function (data) {

                if (data.success) {
                    alert('确认接收成功');
                    $('#btnSubmit').hide();
                }
                else {
                    alert('确认接收失败：' + data.message)
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                var err = XMLHttpRequest + "<br />" + textStatus + "<br />" + errorThrown;
                alert(err);
            }
        });

    }

    function onPrint() {
        //直接在网页上打印
        //document.getElementById("dv1").setAttribute("style", "display:inline");
        //printpage('divPrintArea');
        //document.getElementById("dv1").setAttribute("style", "display:none");

        var form = $("#ExportForm");
        form.submit();
    }

</script>
    @Styles.Render("~/Content/css")
    @Scripts.Render("~/bundles/modernizr")
    @Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/bundles/Common")
    @(Html.Telerik().StyleSheetRegistrar().DefaultGroup(group => group.Add("telerik.common.css").Add("telerik.simple.css").Combined(true).Compress(true)))
    @(Html.Telerik().ScriptRegistrar().Globalization(true).DefaultGroup(group => group.Combined(true).Compress(true)))
